<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
		<link rel="stylesheet" type="text/css" href="../../css/aui-slide.css" />
		<link rel="stylesheet" href="../../css/aliance.css">
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../../css/aui-flex.css">
		<link rel="stylesheet" href="../../css/pulice.css">
		<style>
			.hmShopList> :first-child {
				margin-top: 0;
			}
		</style>
		<script src="../../js/libs/zepto.min.js"></script>
		<script src="../../js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/vue.min.js"></script>
		<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.8&key=1541c9a07778b4a05f644ce5f37391aa&plugin=AMap.Geocoder"></script>
		<script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
		<script>
			//获得参数(只对字母数字等有效,参数值为中文则不能传)
			function getQueryString(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
				var r = window.location.search.substr(1).match(reg);
				if(r != null) return unescape(r[2]);
				return null;
			}

			//获取参数2(对数字、字母、中文均有效.但在对URL进行escape()编码再解码unescape()时不能使用,只能用上述方法)
			function getQueryString2(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
				var r = window.location.search.substr(1).match(reg);
				if(r != null) return decodeURI(r[2]);
				return null;
			}　　
			var hyId = getQueryString('hyId');　　
			var hyName = getQueryString2('hyName');　　
			console.log(hyId);　　
			console.log(hyName);

			$(function() {

				var app = new Vue({
					el: '#app',
					data: {
						hyId: hyId,
						hyName: hyName,
						storePos2: [],
					},
					methods: {
						go_details: function(id) { //方法
								location.href = "details.html?shopId=" + id;

						},
					}
				});

				$('.hm-bar').load('../../data/headerOther.html', function() {
					$(this).find('.head-main').text(hyName);
					$(this).find('.head-left').on('tap', function() {
						window.history.back()
					})
				});

				var map, geolocation;
				//加载地图，调用浏览器定位服务
				map = new AMap.Map('container', {
					resizeEnable: true,
					zoom: 18
				});
				map.plugin('AMap.Geolocation', function() {
					geolocation = new AMap.Geolocation({
						enableHighAccuracy: true, //是否使用高精度定位，默认:true
						timeout: 10000, //超过10秒后停止定位，默认：无穷大
						buttonOffset: new AMap.Pixel(10, 30), //定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
						zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
						buttonPosition: 'RB'
					});
					map.addControl(geolocation);
					geolocation.getCurrentPosition();
					AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
					AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
				});
				//解析定位结果
				var Jing = [];
				var Wei = [];
				var storePos = [];

				function onComplete(data) {
					Jing.push(data.position.getLng());
					Wei.push(data.position.getLat());
					console.log(Jing);
					console.log(Wei);
					$.get(SURL + 'app/shops/storePos', {
						"lng": Jing[0],
						"lat": Wei[0],
						"shopName": "",
						"industry": '1',
						'hyId': hyId
					}, function(res) {
						console.log(res)
						for(var i = 0; i < res.data.length; i++) {
							app.storePos2.push(res.data[i]);
						}
					})

				}
				//解析定位错误信息
				function onError(data) {
					alert('定位失败');
				}

			});
		</script>
		<title></title>
	</head>

	<body style="background: #fff !important">
		<div id="app">
			<!--头部-->
			<div class="hm-bar"></div>
			<div class="nearby-shops">
				<div class="hmMIn">
					<div class="hmShops">
						<ul class="hmShopList">
							<li class="nearby-shop clearFix" v-for="(j,i) in storePos2" @click="go_details(j.shopId)">
								<img class="hmShopImg" :src="orImg(imgUrl+j.logo)" alt="" />
								<div class="hmShopBox">
									<div class="contTit">
										{{j.shopName}}
									</div>
									<div class="contRate clearFix">
										{{j.address}}
									</div>
								</div>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</body>

</html>